<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="/res/back/css/base.css" rel="stylesheet" type="text/css" />
<link href="/res/third/bootstrap3/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="/res/common/js/jquery.1.9.1.min.js" type="text/javascript"></script>
<script src="/res/third/artDialog/jquery.artDialog.js" type="text/javascript"></script>
<script src="/res/third/validate/jquery.validate.js" type="text/javascript"></script>
<script type="text/javascript">


	var fulldialog;
	function fullscreen(id,title){
		fulldialog =art.dialog.fullscreen(title,"/enquiry/v_enquiry_item.do", {'so_enquiryid':id});
	}

	var exceldialog=null;
	function uploaddialog(enquiryid,title){
		var param ={id:enquiryid,title:title};
		
		exceldialog = art.dialog.uploadFile("上传excel",{callback:"uploadcallback",params:JSON.stringify(param),userpath:"admin",extensions:"xls,xlsx"});
	}
	
	
	
	function uploadcallback(response,params){
		exceldialog.close();
		art.dialog.post({
			url:"/enquiry/o_excel_update.do",
			data:{url:response.url,id:params.id},
			success:function(data){
				if(data.success){//更新成功
                    refresh();
                    //setTimeout(function(){
                        //analysis(params.id,params.title,);//分析excel
					//},100)
				}else{
					alert(data.msg);
				}			
			}
		},"更新地址");
	}
	
	/* 分析excel */
	function analysis(id,title,type){
		top.addTempTab("/enquiry/o_retry.do?id="+id+"&type="+type);
/* 		art.dialog.load("正在解析^_^"+title+" 的询价清单","/enquiry/o_retry.do",{id:id},function(data){
			
		}) */
	}

	function mulityAnalysis(id, title, type) {
        top.addTempTab("/enquiry/mulity_retry.do?id="+id+"&type="+type);
    }

	
	//新增测试项目
	function addtest(){
		art.dialog.prompt("标题",function(title){
			art.dialog.post({
				url:"/enquiry/o_add_test.do",
				data:{title:title},
				success:function(data){
					if(data.success){
						refresh();
					}
				}
			},"正在提交");
		});
	}
	//删除
	function delitem(id){
		art.dialog.confirm("确定删除",function(){
			art.dialog.post({
				url:"/enquiry/o_del_item.do",
				data:{id:id},
				success:function(data){
					if(data.success){
						refresh();
					}
				}
			},"删除中");			
		})
	}
	
	function chageenquirystat(id,stat){
		art.dialog.post({
			url:"/enquiry/o_save_item_stat.do",
			data:{id:id,stat:stat},
			success:function(data){
				refresh();
			}
		},"提交中");
	}
</script>
</head>

<body>
	<div class="panel panel-info panel-content">
		<div class="panel-heading">
				<table>
					<tr>
						<td>
							<button type="button" class="btn btn-success" onclick="addtest()" >新增</button>
						</td>
						<td style="display: none;">
							<label>
								&nbsp;&nbsp;&nbsp;&nbsp;<input id="autodelete" type="checkbox"  value="1" checked="checked"  >分析时,某些情况下自动识别并去除无用列
							</label>	
						</td>
					</tr>
				</table>
		</div>
		<table class="table table-hover table-bordered table-striped table-condensed">
			<thead>
				<tr>
					<th>#</th>
					<th>标题</th>
					<th>excel</th>
					<th>标志</th>
					<th>操作</th>
				</tr>
			</thead>
			[#list pagination.list as enquiry ]
			<tr>
				<td>${pagination.pageSize * (pagination.pageNo-1) + enquiry_index+1!}</td>
				<td>${enquiry.title!}</td>
				<td>[#if enquiry.excelpath??  && enquiry.excelpath!="" ]<a target="_blank" href="${enquiry.excelpath}" >有<span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span></a>
				<a target="_blank" href="/enquiry/v_review.do?path=${enquiry.excelpath}"  >预览</a>
				[#else ]无[/#if]
				</td>
				<td>
					[#if enquiry.canread?? &&  enquiry.canread==1 ]
						<button class="btn btn-success btn-xs" title="点击切换状态"  onclick="chageenquirystat(${enquiry.id},0)" >
							可以分析
						</button>
					[#else]
						<button class="btn btn-default btn-xs" title="点击切换状态"  onclick="chageenquirystat(${enquiry.id},1)"  >
							无法分析
						</button>
							
					[/#if]
				</td>
				<td>
				[#if enquiry.items?? && enquiry.items?size != 0 ]
					[#if enquiry.excelpath??  && enquiry.excelpath!="" ] 
						<button type="button" class="btn btn-xs btn-danger" onclick="analysis(${enquiry.id!},'${enquiry.title!}')"  >重新分析</button>
					[/#if]
				[#else]
					[#if enquiry.excelpath??  && enquiry.excelpath!=""]
					<button type="button" class="btn btn-xs btn-danger" onclick="analysis(${enquiry.id!},'${enquiry.title!}',1)"  >询价分析</button>
					<button type="button" class="btn btn-xs btn-danger" onclick="analysis(${enquiry.id!},'${enquiry.title!}',2)"  >报价分析</button>
					[/#if]
				[/#if]
					<button type="button" class="btn btn-xs btn-info"  onclick="mulityAnalysis(${enquiry.id!},'${enquiry.title!}',1)" >mulity_retry</button>
					<button type="button" class="btn btn-xs btn-info" onclick="uploaddialog(${enquiry.id!},'${enquiry.title!}')"  >[#if enquiry.excelpath??  && enquiry.excelpath!="" ]重新[/#if]上传</button>
					<button type="button" class="btn btn-xs btn-info" onclick="delitem(${enquiry.id!})"  >删除</button>
				</td>
			</tr>
			[/#list]
		</table>
		<div class="panel-footer">[@fenye p = pagination form = 'infoForm' /]</div>
		
	</div>
</body>
</html>